local key     = KEYS[1]
local value   = ARGV[1]
local timeout = tonumber(ARGV[2])
local cacheValue = redis.call('setnx', key, value)
if cacheValue==1 then
    if redis.call('expire',KEYS[1],ARGV[2])==1 then
        return 1
    else
        redis.call("del", key)
        return 0
    end
else
    return 0
end